package article_category

import (
	// "fmt"
	"goskeleton/app/global/consts"
	"goskeleton/app/http/validator/core/data_transfer"
	"goskeleton/app/utils/response"

	"goskeleton/app/http/controller/web"

	"github.com/gin-gonic/gin"
)

type Create struct {
	BaseField
}

func (c Create) CheckParams(context *gin.Context) {
	if err := context.ShouldBind(&c); err != nil {
		errs := gin.H{
			"tips": "article_category/create 参数不合规",
			"err":  err.Error(),
		}
		response.ErrorParam(context, errs)
		return
	}
	//获取参数
	//fmt.Println(c.ParentId)
	extraAddBindDataContext := data_transfer.DataAddContext(c, consts.ValidatorPrefix, context)
	if extraAddBindDataContext == nil {
		response.ErrorSystem(context, "UserRegister表单验证器json化失败", "")
	} else {
		// 验证完成，调用控制器,并将验证器成员(字段)递给控制器，保持上下文数据一致性
		(&web.ArticleCategory{}).Create(extraAddBindDataContext)
	}
}
